<!--#include file="Librerias/mssql-ds.dll" -->
<!--#include file="Funciones/SGP.FuncionesGenerales.asp" -->
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
  <head>
    <link rel="StyleSheet" href="Menu/dtree.css" type="text/css" />
    <script type="text/javascript" src="Menu/dtree.js"></script>
  </head>
  <body>
  
    <script type="text/javascript"><!--
      d = new dTree('d');

	<%
	'---------------------------------------  Recupero ID unico de Menu
	qidmenu = request.QueryString("id")
	IF NOT qidmenu>0 THEN qidmenu=0
	
	'--------------------------------------- Recupero datos predeterminados del Menu
	sSQL = "SELECT mtitulo, murl, mframe FROM Menu WHERE idmenu=" & qidmenu
	arbol = MatrixBD(sSQL, 1)
	
	IF VarType(arbol)=8 THEN
		nfilas = -1
	ELSE
		nfilas = UBound(arbol,2)
	END IF
	IF nfilas>=0 THEN
	   qm_titulo=TRIM(arbol(0,0))
	   qm_url=TRIM(arbol(1,0))
	   qm_frame=TRIM(arbol(2,0))
	ELSE
	   qm_titulo="none"
	   qm_url="default.asp"
	   qm_frame="_top"
	END IF
	 
	qm_titulo = SGPNombreProyecto(Request.Cookies("cookie_granted_proyecto_id")) 
	qm_titulo = UCase(qm_titulo)  
	  
	' Cargo Matriz de opciones ordenadas
	sSQL = ""
	sSQL = sSQL & " SELECT idchild, idparent, otitulo, ourl, oframe, oimage FROM Opciones"
	sSQL = sSQL & " WHERE idmenu=" & qidmenu & " AND activo = 1"
	sSQL = sSQL & " ORDER BY idchild ASC"
	arbol = MatrixBD(sSQL, 1)

	IF VarType(arbol)=8 THEN
		nfilas = -1
	ELSE
		nfilas = UBound(arbol,2)
	END IF
	i=0

    response.Write "d.config.target = '"& qm_frame &"';"
    response.Write "d.add(0,-1,'"& qm_titulo &"', '"& qm_url &"','', '"& qm_frame &"');"
	FOR i=0 TO nfilas STEP 1
	  qmo_child = arbol(0,i)
	  qmo_parent = arbol(1,i)
	  qmo_titulo = trim(arbol(2,i))
	  qmo_url = trim(arbol(3,i))
	  qmo_frame = trim(arbol(4,i))
	  qmo_image = trim(arbol(5,i))
	  
	  IF NOT LEN(qmo_url)>1 THEN qmo_url=qm_url
	  IF NOT LEN(qmo_frame)>1 THEN qmo_frame=qm_frame
	  
	  IF NOT LEN(qmo_image)>1 THEN
		response.Write "d.add("& qmo_child &", "& qmo_parent &",'"& qmo_titulo &"', '"& qmo_url &"','', '"& qmo_frame &"');"
	  ELSE
		response.Write "d.add("& qmo_child &", "& qmo_parent &",'"& qmo_titulo &"', '"& qmo_url &"','', '"& qmo_frame &"', '"& qmo_image &"');"	
	  END IF
	NEXT
	%>

      document.write(d);
    //--></script>
    
  </body>
</html>